package it.webrules.deploymanager.core.st.scm;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Log implements Serializable {

	private static final long serialVersionUID = 1L;

	public List<LogEntry> entries;

	public Log() {
		entries = new ArrayList<LogEntry>();
	}

	public LogEntry addEntry(LogEntry logEntry) {
		entries.add(logEntry);
		return logEntry;
	}

	@Override
	public String toString() {

		StringBuilder sb = new StringBuilder();

		sb.append("Revision | Author          |  Date           |         Message\n");
		sb.append("-----------------------------------------------------------------------\n");

		for (LogEntry entry : entries)
			sb.append(entry.toString() + "\n");

		if (entries.size() == 0)
			sb.append("No log.\n");

		return sb.toString();
	}

}
